import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import page from '@/router/page'
const Index = () => import('@/views/Index.vue');
const Login = () => import('@/views/Login.vue');
const mistake = () => import('@/views/404.vue');

const routes = [

  // 首页
  {
    path: "/",
    redirect: "/Index"
  },
  // 首页
  {
    path: "/Index",
    name: "Index",
    component: Index,
    redirect: "/Index/home",
    children: [
      {
        path: "home",
        name: "home",
        meta: {
          title: "首页"
        },
        component: () => import('@/views/Home.vue')
      },
      {
        path: "info",
        name: "info",
        meta: {
          title: "个人信息"
        },
        component: () => import('@/views/userOperation/Userinfo.vue')
      },
      {
        path: "password",
        name: "password",
        meta: {
          title: "密码修改"
        },
        component: () => import('@/views/userOperation/changePassword.vue')
      },
      {
        path: 'Reset/:path(.*)',
        name: "reset",
        component: () => import("@/redirect/Reset.vue"),
      },
      ...page
    ]
  },
  // 登录
  {
    path: "/Login",
    name: "Login",
    component: Login
  },
  {
    path: "/text",
    name: "text",
    component: () => import('@/views/text/index.vue')
  },
  // 错误
  {
    path: "/mistake",
    name: "mistake",
    component: mistake
  },
  {
    path: "/:path(.*)+",
    redirect: "mistake"
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;